﻿@model DataEntity.SysMenu
@using DataAccess

<div style="padding: 10px;">
    @using (Html.BeginForm("", "", FormMethod.Post, new { id = ViewBag.Type + "fm", name = ViewBag.Type + "fm" }))
    {
        <fieldset>
            <legend>基本信息</legend>
            <table class="TableBlock">
                <tr>
                    <td class="TableLabel">
                        @Html.HiddenFor(m => m.ID)
                        @Html.LabelFor(m => m.Name)
                    </td>
                    <td class="TableData">
                        @Html.TextBoxFor(m => m.Name, new { placeholder = "请输入名称", @class = "easyui-validatebox", required = "true" })
                    </td>
                    <td class="TableLabel">
                        @Html.LabelFor(m => m.SortNumber)
                    </td>
                    <td class="TableData">
                        @Html.TextBoxFor(m => m.SortNumber, new { placeholder = "请输入排序号", @class = "easyui-numberbox", required = "true" })
                    </td>
                </tr>
                <tr>
                    <td class="TableLabel">
                        @Html.LabelFor(m => m.IconCss)
                    </td>
                    <td class="TableData">
                        @Html.TextBoxFor(m => m.IconCss, new { placeholder = "请输入图标样式" })
                    </td>
                    <td class="TableLabel">
                        @Html.LabelFor(m => m.ParentID)
                    </td>
                    <td class="TableData">
                        <input id="ParentID" name="ParentID" value="" />
                    </td>
                </tr>
                <tr>
                    <td class="TableLabel">
                        @Html.LabelFor(m => m.MenuUrl)
                    </td>
                    <td class="TableData">
                        @Html.TextBoxFor(m => m.MenuUrl, new { placeholder = "请输入链接地址",style="width:240px;" })
                    </td>
                    <td class="TableLabel">
                        @Html.LabelFor(m => m.IsShow)
                    </td>
                    <td class="TableData">
                        @{
        if (Model.IsShow)
        { 
                            @Html.RadioButtonFor(m => m.IsShow, true, new { id = "IsShowTrue", @checked = true })
                            @Html.RadioButtonFor(m => m.IsShow, false, new { id = "IsShowFalse" })
        }
        else
        {
                            @Html.RadioButtonFor(m => m.IsShow, true, new { id = "IsShowTrue" })
                            @Html.RadioButtonFor(m => m.IsShow, false, new { id = "IsShowFalse", @checked = true })
        }
                        }

                    </td>
                </tr>
            
            </table>
        </fieldset>
        <br />
        <br />
      
        <div style="text-align: right; padding-top: 30px; padding-right: 20px;">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="Save('@ViewBag.Type')">
                保存</a>
        </div>
    }
</div>

<script>
    $(function () {
        var type = "@ViewBag.Type";
        $('#ParentID',"#" + type + "fm").combotree({
            url: "/Menu/MenuJsonForComboTree",
            width: 240,
            onLoadSuccess: function (node, data) {
                $('#ParentID',"#" + type + "fm").combotree("setValue", "@ViewBag.ParentID");
                if (type == "Edit") {
                    //编辑菜单时，父级菜单不显示自己
                    var tree = $('#ParentID',"#" + type + "fm").combotree("tree");
                    var node = tree.tree("find", "@ViewBag.MenuID");
                    tree.tree("remove", node.target);
                }
            },
            onChange:function(newValue, oldValue){
                if(oldValue != 0)
                {
                    //选择父级菜单后，体现父级编码
                    var tree = $('#ParentID',"#" + type + "fm").combotree("tree");
                    var node = tree.tree("find", newValue);
                    $('#SortNumber',"#" + type + "fm").numberbox("setValue",node.attributes.SortNumber + "99");
                }
            }
        });
        //绑定表单验证
        $('#' + type + 'fm').form('validate')
    });

</script>
